(function(factory) {
	if (typeof define === "function" && define.amd) {
		// AMD. Register as an anonymous module.
		define(factory);
	} else {
		// Browser globals
		factory();
	}
}(function() {
	
	Date.prototype.format = function() {
		return this.formatDate() + " " + this.formatTime();
	}

	Date.prototype.formatDate = function() {
		var year = this.getFullYear();
		var month = this.getMonth() + 1;
		var day = this.getDate();
		return year + '-' + month + '-' + day;
	}

	Date.prototype.formatTime = function(s) {
		var hours = this.getHours();
		var minutes = this.getMinutes();
		var seconds = this.getSeconds();
		hours = hours > 9 ? hours : '0' + hours;
		minutes = minutes > 9 ? minutes : '0' + minutes;
		seconds = seconds > 9 ? seconds : '0' + seconds;
		return hours + ":" + minutes + (s === true ? ":" + seconds : "");
	}

	if (!Array.prototype.indexOf) {
		Array.prototype.indexOf = function(obj) {
			for (var i = 0; i < this.length; i++) {
				if (this[i] == obj) {
					return i;
				}
			}
		}
	}
	
	Array.prototype.removeAt = function(index) {
		this.splice(index, 1);
	}
	
	Array.prototype.remove = function(obj) {
		var index = this.indexOf(obj);
		if (index >= 0) {
			this.removeAt(index);
		}
	}
	
	Array.prototype.insert = function(obj,index){
		this.splice(index,0,obj);
	}
	if (!Array.prototype.forEach) {
		Array.prototype.forEach = function(fn){
			var len = this.length;
			for(var i = 0;i < len;i++){
				fn(this[i],i);
			}
		}
	}
}));